package com.mojang.ld22.item;

import com.mojang.ld22.entity.ItemEntity;
import com.mojang.ld22.gfx.Color;
import com.mojang.ld22.gfx.Font;
import com.mojang.ld22.gfx.Screen;

public class ArmorItem extends Item {

	public static final int MAX_LEVEL = 5;
	public static final String[] LEVEL_NAMES = { 
	"Wood", "Rock", "Iron", "Gold", "Gem"
	};

	public static final int[] LEVEL_COLORS = {
	Color.get(-1, 100, 321, 431),
			Color.get(-1, 100, 321, 111),
			Color.get(-1, 100, 321, 555),
			Color.get(-1, 100, 321, 550),
			Color.get(-1, 100, 321, 055),
	};

	public int level = 0;

	public ArmorItem(final int level) {
		this.level = level;
	}

	public int getColor() {
		return LEVEL_COLORS[level];
	}

	public int getSprite() {
		return 5 + 5 * 32;
	}

	public void renderIcon(Screen screen, int x, int y) {
		screen.render(x, y, getSprite(), getColor(), 0);
	}

	public void renderInventory(Screen screen, int x, int y) {
		screen.render(x, y, getSprite(), getColor(), 0);
		Font.draw(getName(), screen, x + 8, y, Color.get(-1, 555, 555, 555));
	}

	public String getName() {
		return LEVEL_NAMES[level] + " Shd.";
	}

	public void onTake(ItemEntity itemEntity) {
	}

	public boolean canAttack() {
		return false;
	}

	public boolean matches(Item item) {
		if (item instanceof ArmorItem) {
			ArmorItem other = (ArmorItem) item;
			if (other.level != level) return false;
			return true;
		}
		return false;
	}
}